Skip to main content

On Message Received Callback

  • Purpose:
    Manages notifications received from the SDK.
  • Functionality:
    • Stores notifications or processes them immediately via the processNotification function.
  • Usage:
    Ensures that notifications are either deferred for later review or immediately acted upon, maintaining a responsive user experience.

  • Example:
onMessageReceivedCallback: async (notifications: Notification[]) => {
console.log("onMessageReceivedCallback:", notifications);
// Ensure agentInstance is initialized
if (!agentInstance) {
console.error("Agent is not initialized");
return false;
}
notifications.forEach(async (notification) => {
try {
const result = await agentInstance.notificationManager?.process(
notification.id
);
console.log(
"Processed notification:",
notification.id,
"Result:",
result
);
} catch (error) {
console.error(`Error processing notification ${notification.id}:`, error);
}
});
return true;
};
X

Graph View